#创建列表
arr = []
arr = list()
arr = list("abc")
arr = list(range(0, 11))
arr = ["hello", 2, 3.14, True, 2 + 3j, print]
arr = [i * 20 for i in range(0, 10)]
arr = [i for i in range(1, 101) if i % 3 == 0 and i % 5 == 0]
lis = [1, 5, 6, 7]
#先执行if然后才执行 i + 1 所以结果为7
arr = [i + 1 for i in lis if i % 2 == 0]
# arr = list(map(int, input().split(" ")))
# arr = [int(i) for i in input().split(" ")]
arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
arr2 = [100, 200, 300]

arr1.insert(-20, 20)
arr1.insert(200, 50)
arr1.append(100)
# arr1.extend(arr2)
# arr1.append(arr2)
arr1.remove(50)
arr1.pop(0)
del arr1[2:6:]
# print(arr1)
# arr2 = ['a', 'b', 'c']
# arr3 = arr1 + arr2
# print(arr3 * 3)
# print(arr[-2:2:-2])

# print(len(arr1))
# print(min(arr1))
# print(max(arr1))
# print(sum(arr1))
# help()

# arr = [5,9,7,1,2,3,6,4,200,1,1,0,0,0,1,1,1,0,0,1]
# brr = arr.copy()
# arr.reverse()
# print(arr.count(1))
# print(brr)
arr = [1, 2, 3, 4, 5, 6, 7]
# for index in range(len(arr)):
#     arr[index] **= 2
#     print(arr[index])
# print(arr)
# for element in arr:
#     element **= 2
#     print(element)
# print(arr)
# for index, element in enumerate(arr):
#     print(f'arr[{index}]={element}')
def min_max(arr:list[int]) -> tuple:
    min_value = arr[0]
    max_value = arr[0]
    for element in arr:
        if min_value > element:
            min_value, element = element, min_value
        if max_value < element:
            max_value, element = element, max_value
    return min_value, max_value

def is_exit(arr:list[int], key:int) -> bool:
    for element in arr:
        if element == key:
            return True
    return False

def list_reverse(arr:list[int]) -> None:
    i = len(arr) - 1
    while i >= 0:
        print(arr[i], end = " ")
        i -= 1

arr = [1,2,3,9,8,7,4,5,6,500,-85]
# min_value, max_value = min_max(arr)
# print(min_value, max_value)
# print(is_exit(arr,57))
# print(list_reverse(arr))

import random
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

def list_shuffle(arr:list[int]):
    for i in range(len(arr)):
        j = random.randint(0, len(arr) - 1)
        arr[i], arr[j] = arr[j], arr[i]

# list_shuffle(arr)
# print(arr)
def print_matrix(matrix):
    for i in range(len(matrix)):
        for j in range(len(matrix[i])):
            print(matrix[i][j], end = " ")
        print()
# rows = 3
# cols = 6
# matrix = []
# for i in range(rows):
#     row = [0] * cols
#     matrix.append(row)
# matrix[2][2] = 100
# print(matrix)
# print_matrix(matrix)
rows = 3
cols = 5
# matrix = [[0] * 6 for _ in range(rows)]
# matrix = [[i + j for j in range(cols)] for i in range(rows)]
# print_matrix(matrix)
def binary_search(arr, key):
    left = 0
    right = len(arr) - 1
    mid = 0
    while arr[mid] != key:
        mid = (left + right) // 2
        if key > arr[mid]:
            left = mid + 1
        elif key < arr[mid]:
            right = mid - 1
        if left > right:
            return -1
    return mid

# mid = (key - arr[left]) / (arr[right] - arr[left]) * (right - left) + left
def interpalotion_search(arr, key):
    left = 0
    right = len(arr) - 1
    mid = int((key - arr[left]) / (arr[right] - arr[left]) * (right - left)) + left
    while arr[mid] != key:
        if arr[mid] < key:
            left = mid + 1
        elif key < arr[mid]:
            right = mid - 1
        if left > right:
            mid  = -1
            break
        mid = int((key - arr[left]) / (arr[right] - arr[left]) * (right - left)) + left


# arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
# print(binary_search(arr, 100))

#选择排序
def selection_sort(arr):
    for i in range(len(arr) - 1):
        for j in range(i + 1, len(arr)):
            if arr[i] > arr[j]:
                arr[i], arr[j] = arr[j], arr[i]

#冒泡排序
def bubble_sort(arr):
    for i in range(len(arr) - 1):
        for j in range(len(arr) -i -1):
            if arr[j] > arr[j + 1]:
                arr[j], arr[j + 1] = arr[j + 1], arr[j]

#插入排序
def insertion_sort(arr):
    for i in range(1, len(arr)):
        j = i
        while j > 0 and arr[j - 1] > arr[j]:
            arr[j - 1], arr[j] = arr[j], arr[j - 1]
            j -= 1


arr = [5, 6, 9, 1, 2, 4]
# selection_sort(arr)
# bubble_sort(arr)
insertion_sort(arr)
print(arr)


